const express = require('express');
const mongoose = require('mongoose');
const user = require('./router/user');
mongoose.connect('mongodb://localhost:27017/exprss-demo', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  userFindAndModify: false
});
const db = mongoose.connection;
db.on('error', () => {
  console.log('connecte error');
});
db.once('open', () => {
  console.log('connected')
})
const app = express();
app.use(express.json());
app.use('/api/user', user);
app.use((err, req, res, next) => {
  res.status(500).json(err);
})
app.listen(8888, () => {
  console.log('app listening at 8888');
});